/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TableModels;

import Entities.Exhibitor;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author manhnv_b00954
 */
public class ExhibitorTableModel extends AbstractTableModel{
    ArrayList<Exhibitor> arrList;

    public ExhibitorTableModel() {
    }

    public ExhibitorTableModel(ArrayList<Exhibitor> arrList) {
        this.arrList = arrList;
    }

    @Override
    public int getRowCount() {
        return arrList.size();
    }

    @Override
    public int getColumnCount() {
        return 12;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Object value = null;
        Exhibitor objExhibitor = arrList.get(rowIndex);
        switch(columnIndex){
            case 0:
                value = objExhibitor.getId();
                break;
            case 1:
                value = objExhibitor.getFirstName() +" " + objExhibitor.getLastName();
                break;
            case 2:
                value = objExhibitor.getSex();
                break;
            case 3:
                value = objExhibitor.getEmail();
                break;
            case 4:
                value = objExhibitor.getPhone();
                break;
            case 5:
                value = objExhibitor.getAddress()+" "+objExhibitor.getCity()+" "+objExhibitor.getCountry();
                break;
            case 6:
                if(objExhibitor.getStatus() == 0){
                    value = "Normal";
                }else if (objExhibitor.getStatus() == 1){
                    value = "Block";
                }else{
                    value = "Deleted";
                }
               // value = objExhibitor.getStatus();
                break;
            case 7:
                value = objExhibitor.getIdentityCardNumber();
                break;
            case 8:
                value = objExhibitor.getAccountBank()+",  "+objExhibitor.getBankName();
                break;
            case 9:
                value = objExhibitor.getOrganizationName();
                break;
            case 10:
                value = objExhibitor.getRegisterDate();
                break;
            default:
                value = objExhibitor.getModifiedDate();
                break;
        }
        return value;
    }

    @Override
    public String getColumnName(int column) {
        String columName;
        switch(column){
            case 0:
                columName = "ID";
                break;
            case 1:
                columName = "Full Name";
                break;
            case 2:
                columName = "Sex";
                break;
            case 3:
                columName = "Email";
                break;
            case 4:
                columName = "Phone";
                break;
            case 5:
                columName = "Address";
                break;
            case 6:
                columName = "Status";
                break;
            case 7:
                columName = "Identity Card";
                break;
            case 8:
                columName = "Account Bank";
                break;
            case 9:
                columName = "Organization";
                break;
            case 10:
                columName = "Register Date";
                break;
            default:
                columName = "Modified Date";
                break;
        }
        return columName;
    }
    
}
